/**
 * 
 */
package common.util;

import org.apache.log4j.Logger;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 读取properties文件工具类(修改后，可以立即生效)
 * 
 * @author WangXin
 * 
 */
public class PropertiesUtil {
	private static final String config_file_properties = "/application.properties";
	private static final Logger logger = Logger.getLogger(PropertiesUtil.class);
	/**
	 * 获取某个属性
	 */
	public static String getString(String key) {
		return getString(config_file_properties,key);
	}

	public static String getString(String filePath, String key) {
		Properties props = new Properties();
		InputStream in = null;
		String value = "";
		try {
			in = PropertiesUtil.class.getResourceAsStream(filePath);
			props.load(in);
			value = props.getProperty(key);
		} catch (Exception e) {
			logger.error(e);
		} finally {
			try {
				in.close();
			} catch (IOException e) {
				logger.error(e);
			}
		}
		return value;
	}

}
